package com.itheima.service.system.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.common.utils.UtilFuns;
import com.itheima.dao.system.SyslogDao;
import com.itheima.doamin.system.SysLog;
import com.itheima.service.system.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService{
    @Autowired
    SyslogDao syslogDao;
    /**
     * 保存日志
     *
     * @param sysLog
     */
    @Override
    public void save(SysLog sysLog) {
        sysLog.setId(UtilFuns.getUUID());
        syslogDao.save(sysLog);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public PageInfo queryAllLog(int page,int size) {
        PageHelper.startPage(page,size);
        List<SysLog> sysLogs = syslogDao.queryAllLog();
        PageInfo pageInfo=new PageInfo(sysLogs);
        return pageInfo;
    }

    @Override
    public List getOnlineData() {
        return syslogDao.selectOnlineData();
    }
}
